package Lambda;

import java.io.Serializable;
import java.text.CollationKey;
import java.text.Collator;
import java.util.Comparator;
import java.util.Objects;

public class Employee implements Serializable, Comparator<Employee> {
    private long No;
    private String name;
    private int age;
    private double salary;
    private String department;
    private Status status;


    public Employee(){

    }

    public Employee(long no, String name, int age, double salary, String department) {
        No = no;
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.department = department;
    }

    public Employee(long no, String name, int age, double salary, String department, Status status) {
        No = no;
        this.name = name;
        this.age = age;
        this.salary = salary;
        this.department = department;
        this.status = status;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public long getNo() {
        return No;
    }

    public void setNo(long no) {
        No = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    @Override
    public int compare(Employee o1, Employee o2) {
        Collator collator=Collator.getInstance();
        CollationKey collationKey1 = collator.getCollationKey(o1.getName());
        CollationKey collationKey2 = collator.getCollationKey(o2.getName());
        return collationKey1.compareTo(collationKey2);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Employee)) return false;
        Employee employee = (Employee) o;
        return getNo() == employee.getNo() &&
                getAge() == employee.getAge() &&
                Double.compare(employee.getSalary(), getSalary()) == 0 &&
                Objects.equals(getName(), employee.getName()) &&
                Objects.equals(getDepartment(), employee.getDepartment());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getNo(), getName(), getAge(), getSalary(), getDepartment());
    }

    @Override
    public String toString() {
        return "Employee{" +
                "No=" + No +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                ", department='" + department + '\'' +
                ",STATUS='"+status+'\''+
                '}';
    }

    public enum Status{
        FREE,
        BUSY,
        VOCATION
    }
}
